import { GSprite } from "../../../../../../com/mui/controls/GSprite";
import { ObjCreate } from "../../../common/ObjCreate";
import { GuildEliteGroupPanelGroupRenderer } from "./GuildEliteGroupPanelGroupRenderer";
import { ScrollPolicy } from "../../../../../../fl/controls/ScrollPolicy";
import { DataProvider } from "../../../../../../fl/data/DataProvider";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { DataEvent } from "../../../../events/DataEvent";
import { GModuleEvent } from "../../../../mvc/GModuleEvent";
import { SGuildGroupPlayer } from "../../../../../../Message/Public/SGuildGroupPlayer";
import { GTileList } from "../../../../../../com/mui/controls/GTileList";
import { ScaleBitmap } from "../../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class GuildEliteGroupPanelGroup
    
    export  class GuildEliteGroupPanelGroup extends GSprite
    {
        constructor(arg1: int)
        {
            super();
            this._index = arg1;
            this.initUI();
            this.mouseEnabled = false;
            return;
        }

        /* internal  */initUI(): void
        {
            this._bg = ObjCreate.createBg(0, 0, 125, 126, this);
            this._list = ObjCreate.createTileList(0, 5, 125, 126, this);
            this._list.rowHeight = 23;
            this._list.columnWidth = 125;
            this._list.setStyle("cellRenderer", GuildEliteGroupPanelGroupRenderer);
            this._list.scrollPolicy = ScrollPolicy.OFF;
            this._listDp = new DataProvider();
            this._list.dataProvider = this._listDp;
            this._btnSp = new Object /* flash.display.Sprite */();
            this._btnSp.x = 57;
            this._btnSp.y = 119;
            this._btnSp.buttonMode = true;
            this.addChild(this._btnSp);
            this._btnBm = new Object /* flash.display.Bitmap */();
            this._btnBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.SmalAwBtn);
            this._btnSp.addChild(this._btnBm);
            this._btnSp.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._isSmall = !this._isSmall;
            this.updateSize();
            this.dispatchEvent(new DataEvent(GModuleEvent.GuildGroup_GroupPanelSizeChange));
            return;
        }

        /* internal  */updateSize(): void
        {
            if (this._isSmall) 
            {
                this._btnBm.y = 8;
                this._btnBm.rotationX = 180;
                this._bg.height = 20;
                this._btnSp.y = 13;
                this._list.height = 10;
            }
            else 
            {
                this._btnBm.y = 0;
                this._btnBm.rotationX = 0;
                this._bg.height = 126;
                this._btnSp.y = 119;
                this._list.height = 126;
            }
            return;
        }

        public updateDataProvider(arg1: DataProvider): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            this._listDp.removeAll();
            if (arg1) 
            {
                loc2 = arg1.length;
                loc1 = 0;
                while (loc1 < loc2) 
                {
                    if (loc3 = arg1.getItemAt(loc1) as SGuildGroupPlayer) 
                    {
                        this._listDp.addItem(loc3);
                    }
                    ++loc1;
                }
            }
            this._list.dataProvider = this._listDp;
            return;
        }

        public /* override */ get height(): number
        {
            if (this._isSmall) 
            {
                return 20;
            }
            return 126;
        }

        /* internal */ /* var */_isSmall: Boolean=false;

        /* internal */ /* var */_index: int;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_listDp: DataProvider;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_btnSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_btnBm: Object /* flash.display.Bitmap */;
    }
